load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "telemetry",
    srcs = [
        "data.go",
        "data_cluster_hardware.go",
        "data_cluster_info.go",
        "data_feature_usage.go",
        "data_slow_query.go",
        "data_telemetry_host_extra.go",
        "data_window.go",
        "id.go",
        "status.go",
        "telemetry.go",
        "ttl.go",
        "util.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/telemetry",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/utils",
        "//pkg/config",
        "//pkg/domain/infosync",
        "//pkg/infoschema",
        "//pkg/kv",
        "//pkg/metrics",
        "//pkg/parser/ast",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/sessionctx",
        "//pkg/sessionctx/variable",
        "//pkg/util/logutil",
        "//pkg/util/memory",
        "//pkg/util/sqlexec",
        "@com_github_google_uuid//:uuid",
        "@com_github_iancoleman_strcase//:strcase",
        "@com_github_pingcap_errors//:errors",
        "@com_github_prometheus_client_golang//api",
        "@com_github_prometheus_client_golang//api/prometheus/v1:prometheus",
        "@com_github_prometheus_common//model",
        "@com_github_shirou_gopsutil_v3//cpu",
        "@com_github_shirou_gopsutil_v3//host",
        "@com_github_tikv_client_go_v2//metrics",
        "@io_etcd_go_etcd_client_v3//:client",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "telemetry_test",
    timeout = "short",
    srcs = [
        "data_cluster_hardware_test.go",
        "data_feature_usage_test.go",
        "data_window_test.go",
        "main_test.go",
        "telemetry_test.go",
        "util_test.go",
    ],
    embed = [":telemetry"],
    flaky = True,
    shard_count = 35,
    deps = [
        "//pkg/autoid_service",
        "//pkg/config",
        "//pkg/domain",
        "//pkg/kv",
        "//pkg/parser/model",
        "//pkg/session",
        "//pkg/sessionctx",
        "//pkg/sessionctx/variable",
        "//pkg/store/mockstore",
        "//pkg/store/mockstore/unistore",
        "//pkg/testkit",
        "//pkg/testkit/testsetup",
        "@com_github_jeffail_gabs_v2//:gabs",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//testutils",
        "@io_etcd_go_etcd_tests_v3//integration",
        "@org_uber_go_goleak//:goleak",
    ],
)
